package cn.com.yusys.yusp.admin.service;

import java.util.List;
import java.util.Map;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import cn.com.yusys.yusp.commons.dto.def.ContrBean;
import cn.com.yusys.yusp.commons.dto.def.DataContrDTO;
import cn.com.yusys.yusp.commons.dto.def.MenuContrDTO;
import cn.com.yusys.yusp.commons.dto.def.UserInfoDTO;

/**
 * 用户信息获取客户端.
 * 
 *
 * @author dusong
 * @since 2.1.1
 */
@FeignClient(fallback = UserProviderServiceHystrix.class, name = "${service.feignclient.name.yusp-app-oca:yusp-app-oca}", path = "/api")
public interface UserProviderService {

    @RequestMapping(method = RequestMethod.GET, value = "/contr/url")
    public List<ContrBean> getAllContrUrl();

    @RequestMapping(method = RequestMethod.GET, value = "/user/usercode")
    public String getUserCode();

    @RequestMapping(method = RequestMethod.GET, value = "/session/info")
    public UserInfoDTO getUserInfo(@RequestParam("loginCode") String loginCode, @RequestParam("sysId") String sysId);

    @RequestMapping(method = RequestMethod.GET, value = "/account/menuandcontr")
    public MenuContrDTO getMenuandContr(@RequestParam("loginCode") String loginCode,@RequestParam("sysId") String sysId);

    @RequestMapping(method = RequestMethod.GET, value = "/account/dataauth")
    public List<DataContrDTO> getDataAuth(@RequestParam("loginCode") String loginCode,
            @RequestParam("sysId") String sysId);

    @RequestMapping(method = RequestMethod.GET, value = "/contr/clearUrl")
    public void cleanAllContrUrlCache();

    @RequestMapping(method = RequestMethod.GET, value = "/cleanUserInfoCache")
    public void cleanUserInfoCache();

    @RequestMapping(method = RequestMethod.GET, value = "/cleanMenuAndContrCache")
    public void cleanMenuAndContrCache();

    @RequestMapping(method = RequestMethod.GET, value = "/cleanDataContrCache")
    public void cleanDataContrCache();

    /**
     * 通过机构查询该机构下所有用户
     * 
     * @param orgId
     * @return
     */
    @GetMapping(value = "/user/org/{orgId}")
    public List<String> queryUserByOrgId(@PathVariable("orgId") String orgId);

    /**
     * 通过机构id查询所属机构下用户信息
     * 
     * @param orgIds
     * @return
     */
    @PostMapping(value = "/user/orgs")
    public List<String> queryUserByOrgIds(@RequestBody List<String> orgIds);

    /**
     * 通过角色id查询属于该角色的所有用户
     * 
     * @param roleId
     * @return
     */
    @GetMapping(value = "/user/role/{roleId}")
    public List<String> queryUserByRoleId(@PathVariable("roleId") String roleId);

    /**
     * 通过部门id查询属于该部门下所有的用户信息
     * 
     * @param dutyId
     * @return
     */
    @GetMapping(value = "/user/duty/{dutyId}")
    public List<String> queryUserByDutyId(@PathVariable("dutyId") String dutyId);

    /**
     * 通过用户id查询该用户所属机构id
     * 
     * @param userId
     * @return
     */
    @GetMapping(value = "/org/user/{userId}")
    public List<String> queryOrgsByUserId(@PathVariable("userId") String userId);

    /**
     * 通过上级机构id查询所有的上级机构id属于该上级机构id
     * 
     * @param upOrgId
     * @return
     */
    @GetMapping(value = "/org/uporg/{upOrgId}")
    public List<String> queryOrgsByUpOrgId(@PathVariable("upOrgId") String upOrgId);

    /**
     * 根据机构id查询该机构的上级机构
     * 
     * @param orgId
     * @return
     */
    @GetMapping(value = "/uporg/org/{orgId}")
    public List<String> queryUpOrgByOrgId(@PathVariable("orgId") String orgId);

    /**
     * 根据用户id查询用户信息
     * 
     * @param userId
     * @return
     */
    @GetMapping(value = "/user/{userId}")
    public Map<String, Object> queryUserInfoByUserId(@PathVariable("userId") String userId);

}